package com.ouc.yyi.springbootwebapp.controller;

import com.cebbank.yyi.impl.Impl;
import connection.IDbUtil;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

@RestController
public class StarterController {

//    @Autowired
//    private IDbUtil dbUtil;
    @Autowired
    private Impl impl;

    @GetMapping("/stater")
    @SneakyThrows
    public void test() {
        String sql = "SELECT ID id, USER_NAME userName,  DESCRIPTION description FROM USER_INFO WHERE ID = ?";
        PreparedStatement stat = impl.getSate(sql, "1");
        ResultSet resultSet = stat.executeQuery();
        while (resultSet.next()) {
            String id = resultSet.getString(1);
            String userName = resultSet.getString(2);
            String description = resultSet.getString(3);
            System.err.println("id:" + id + " userName:" + userName + "description:" + description);
        }
        //dbUtil.close(stat);

    }
}
